/*
 * mvb.h
 *
 *  Created on: 2024年12月12日
 *      Author: Administrator
 */

#ifndef MVB_MVB_H_
#define MVB_MVB_H_
#include "MyFreertos.h"
#include "board.h"
#include "fsl_debug_console.h"
#include "fsl_device_registers.h"
#include "pin_mux.h"
#include "fsl_semc.h"
#include "clock_config.h"

#define PI_BASE_ADDR	0x90000000
#define PCS_BASE_ADDR	0x90002000
#define DATA_BASE_ADDR	0x90004000
//#define DEVICE_BASE_ADDR	0x90040000
//#define DEVICE_STATUS_ADDR	0x90060000
#define LIFE_BASE_ADDR	0x90020000
#define MASTER_FRAME_TABLE_BASE_ADDR	0x90010000
#define MASTER_FRAME_TIME_BASE_ADDR	0x90018000


struct port_data_t{
	unsigned int port;
	unsigned int bytes;
	unsigned short data[16];
	unsigned short dataweb[18];
	unsigned short index;
	unsigned short fcode;
	unsigned int attr;
};



struct MVB_INFO{
	unsigned short pPort;
	unsigned short pFcode;
	unsigned short VP;
	unsigned short PI;
	unsigned int PCS0;
	unsigned int PCS1;
	unsigned int PCS2;
	unsigned int PCS3;
	unsigned int DataBaseAddr;
	unsigned short data[16];
	unsigned char *p_data_bytes;
	unsigned short frameLife;
	unsigned short globalLife;
};

extern uint16_t mvb_send_137[16], mvb_send_702[16], mvb_send_706[16];

/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define EXAMPLE_SEMC SEMC
#define EXAMPLE_SEMC_CLK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Semc)

/*******************************************************************************
 * Prototypes
 ******************************************************************************/
#define SRAM_BASE 0x90000000
status_t MvbInit(void);
int writeMasterFrameTable(void);
void writeConfig(void);
void test_sram(void);
void MvbSend();
void MvbRecv();
#endif /* MVB_MVB_H_ */
